public class test15 {
    //    public static void test{
//        String str ="hello-world";
//        String[] split =str.split("-");
//        for (int i =0;i<str.length();i++){
//            System.out.println(split[i]);
//        }
//    }
//    public static void test01() {
//        String str = "hello-world";
//        String[] split = str.split("-");
//        for (int i = 0; i < split.length; i++) {
//            System.out.println(split[i]);
//        }
//    }

    public static void main(String[] args) {
        //test01();
        //System.out.println(test02("HELLOWORLD","O"));
//        test03();
//        test04();
        test05("12122345");
    }

    //输入一个字符串，统计该字符串中某个单字符串出现的次数
//    public static int test02(String input, String word) {
//        String[] strs = new String[input.length()];
//        int count=0;
//        for (int i = 0; i < input.length(); i++) {
//            strs[i] = input.substring(i, i + 1);
//            //System.out.println(strs[i]);
//            if (strs[i].equals(word)){
//                count++;
//            }
//        }
//        System.out.println(count);
//        return 1;
//    }

    public static void test03(){
        String str = "helloworldxxx" ;
        int position = str.indexOf("llo");
        System.out.println(position);
       char c = str.charAt(4);
        System.out.println(c);

//替换
        System.out.println(str);
        str = str.replace('x','y');
        System.out.println(str);
    }
  public static void test04(){
//       StringBuffer sb = new StringBuffer("abc") ;
//       sb.append("xxx");
//       sb.insert(2,"bbb");
//      System.out.println(sb);
//      sb.reverse();   //颠倒,逆序
//      System.out.println(sb);

      // String->StringBuffer
      String a = "hello";
      StringBuffer sb2 = new StringBuffer(a) ;

      //StringBuffer->String
     //String b = sb2.toString();
      String c = sb2 + "" ;//任何类型遇到字符串 都会转为字符串
      System.out.println(c);
  }
    public static void test05(String digital){
        StringBuffer sb= new StringBuffer(digital);
        for (int i = digital.length()-3 ;i>0;i=i-3){
            sb.insert(i,",");
        }
        System.out.println(sb);
    }
}